﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using RuTracker.WebSite.DbLayer;
using RuTrackerLib;
using RuTrackerLib.ServiceAttibutes;

namespace RuTracker.WebSite.IoC.Installers
{
    public class PerSessionInstaller : IWindsorInstaller 
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Classes.FromAssembly(typeof(LibAssemblyMarker).Assembly)
                .Where(Component.HasAttribute<PerSessionServiceAttribute>(_ =>  true))
                .WithService.AllInterfaces()
                .LifestyleCustom<PerSessionLifestyleManager>());

            container.Register(Classes.FromAssembly(typeof(DataLayerAssemblyMarker).Assembly)
                .Where(Component.HasAttribute<PerSessionServiceAttribute>(_ => true))
                .WithService.AllInterfaces()
                .LifestyleCustom<PerSessionLifestyleManager>());
        }
    }
}
